﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Web.UI;
using System.Collections;

namespace Timeline
{
    public class TimelineAdditionalIndicatorCollection : ICollection<TimelineAdditionalIndicator>
    {
        #region Member variables

        private List<TimelineAdditionalIndicator> _values = new List<TimelineAdditionalIndicator>();
        private string _labelCssClass;
        private string _labelArrowCssClass;
        private string _toolTip;
        private string _onClickJS;

        #endregion

        #region Properties

        public TimelineAdditionalIndicator AdditionalIndicator
        {
            set { Add(value); }
        }

        /// <summary>
        /// Gets or sets the label CSS class.
        /// </summary>
        /// <value>
        /// The label CSS class.
        /// </value>
        [Bindable(true), Category("Values"), DefaultValue(""), Description("Css class to use for setting the label (overridden by timeline additional indicator label css class).")]
        public string LabelCssClass
        {
            get { return _labelCssClass; }
            set { _labelCssClass = value; }
        }

        /// <summary>
        /// Gets or sets the label arrow CSS class.
        /// </summary>
        /// <value>
        /// The label arrow CSS class.
        /// </value>
        [Bindable(true), Category("Values"), DefaultValue(""), Description("Css class to use for setting the label arrow (overridden by timeline additional indicator label arrow css class).")]
        public string LabelArrowCssClass
        {
            get { return _labelArrowCssClass; }
            set { _labelArrowCssClass = value; }
        }

        /// <summary>
        /// Gets or sets the tool tip.
        /// </summary>
        /// <value>
        /// The tool tip.
        /// </value>
        [Bindable(true), Category("Values"), DefaultValue(""), Description("Tool tip (overridden by timeline additional indicator tooltip).")]
        public string ToolTip
        {
            get { return _toolTip; }
            set { _toolTip = value; }
        }

        /// <summary>
        /// Gets or sets the on click js.
        /// </summary>
        /// <value>
        /// The on click js.
        /// </value>
        [Bindable(true), Category("Values"), DefaultValue(""), Description("OnClick javascript.")]
        public string OnClickJS
        {
            get { return _onClickJS; }
            set { _onClickJS = value; }
        }

        #endregion

        #region Constructors

        /// <summary>
        /// Initializes a new instance of the <see cref="TimelineAdditionalIndicatorCollection"/> class.
        /// </summary>
        public TimelineAdditionalIndicatorCollection()
        {

        }

        /// <summary>
        /// Initializes a new instance of the <see cref="TimelineAdditionalIndicatorCollection"/> class.
        /// </summary>
        /// <param name="labelCssClass">The label CSS class.</param>
        /// <param name="labelArrowCssClass">The label arrow CSS class.</param>
        /// <param name="toolTip">The tool tip.</param>
        /// <param name="onClickJS">The on click js.</param>
        public TimelineAdditionalIndicatorCollection(string labelCssClass, string labelArrowCssClass, string toolTip, string onClickJS)
        {
            LabelCssClass = labelCssClass;
            LabelArrowCssClass = labelArrowCssClass;
            ToolTip = toolTip;
            OnClickJS = OnClickJS;
        }

        #endregion

        #region Interface implementation

        /// <summary>
        /// Adds an item to the <see cref="T:System.Collections.Generic.ICollection`1" />.
        /// </summary>
        /// <param name="item">The object to add to the <see cref="T:System.Collections.Generic.ICollection`1" />.</param>
        public void Add(TimelineAdditionalIndicator item)
        {
            _values.Add(item);
        }

        /// <summary>
        /// Removes all items from the <see cref="T:System.Collections.Generic.ICollection`1" />.
        /// </summary>
        public void Clear()
        {
            _values.Clear();
        }

        /// <summary>
        /// Determines whether the <see cref="T:System.Collections.Generic.ICollection`1" /> contains a specific value.
        /// </summary>
        /// <param name="item">The object to locate in the <see cref="T:System.Collections.Generic.ICollection`1" />.</param>
        /// <returns>
        /// true if <paramref name="item" /> is found in the <see cref="T:System.Collections.Generic.ICollection`1" />; otherwise, false.
        /// </returns>
        public bool Contains(TimelineAdditionalIndicator item)
        {
            return _values.Contains(item);
        }

        /// <summary>
        /// Copies to.
        /// </summary>
        /// <param name="array">The array.</param>
        /// <param name="arrayIndex">Index of the array.</param>
        public void CopyTo(TimelineAdditionalIndicator[] array, int arrayIndex)
        {
            _values.CopyTo(array, arrayIndex);
        }

        /// <summary>
        /// Gets the number of elements contained in the <see cref="T:System.Collections.Generic.ICollection`1" />.
        /// </summary>
        /// <returns>The number of elements contained in the <see cref="T:System.Collections.Generic.ICollection`1" />.</returns>
        public int Count
        {
            get { return _values.Count; }
        }

        /// <summary>
        /// Gets a value indicating whether the <see cref="T:System.Collections.Generic.ICollection`1" /> is read-only.
        /// </summary>
        /// <returns>true if the <see cref="T:System.Collections.Generic.ICollection`1" /> is read-only; otherwise, false.</returns>
        public bool IsReadOnly
        {
            get { return false; }
        }

        /// <summary>
        /// Removes the first occurrence of a specific object from the <see cref="T:System.Collections.Generic.ICollection`1" />.
        /// </summary>
        /// <param name="item">The object to remove from the <see cref="T:System.Collections.Generic.ICollection`1" />.</param>
        /// <returns>
        /// true if <paramref name="item" /> was successfully removed from the <see cref="T:System.Collections.Generic.ICollection`1" />; otherwise, false. This method also returns false if <paramref name="item" /> is not found in the original <see cref="T:System.Collections.Generic.ICollection`1" />.
        /// </returns>
        public bool Remove(TimelineAdditionalIndicator item)
        {
            return _values.Remove(item);
        }

        /// <summary>
        /// Returns an enumerator that iterates through the collection.
        /// </summary>
        /// <returns>
        /// A <see cref="T:System.Collections.Generic.IEnumerator`1" /> that can be used to iterate through the collection.
        /// </returns>
        public IEnumerator<TimelineAdditionalIndicator> GetEnumerator()
        {
            return _values.GetEnumerator();
        }

        /// <summary>
        /// Returns an enumerator that iterates through a collection.
        /// </summary>
        /// <returns>
        /// An <see cref="T:System.Collections.IEnumerator" /> object that can be used to iterate through the collection.
        /// </returns>
        IEnumerator IEnumerable.GetEnumerator()
        {
            return _values.GetEnumerator();
        }

        #endregion
    }
}